#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int func(int n)
{
    int count2 = 0;
    for (int i = 0; i <= n; i++)
    {
        int i1 = i;
        int count1 = 1;
        while ((i1 / 10) > 0)
        {
            count1++;
            i1 /= 10;
        }
        int t = (int)pow(10, count1);
        if (((i * i) % t) == i)
        {
            count2++;
        }
    }
    return count2;
}
int main() {
    int n;
    int c;
    while (scanf("%d", &n) != EOF)
    {
        c = func(n);
        printf("%d\n", c);
    }
    return 0;
}